const getDefaultState = () => {
  return {
    socket: null,
    message: null,
  };
};

const state = getDefaultState();

const mutations = {
  WEBSOCKET: (state, socket) => {
    state.socket = socket;
  },
  SET_MESSAGE: (state, message) => {
    state.message = message;
  },
};

const actions = {
  // 全局系统缓存socket链接对象
  setWebSocket({ commit }, socket) {
    commit("WEBSOCKET", socket);
  },

  // 清除socket链接对象
  setSocketMessage({ commit }, message) {
    commit("SET_MESSAGE", message);
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
